<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head th:include="css :: css">

</head>
<body>

<!--<div th:include="common :: header"></div>-->

<div id="cl-wrapper" class="fixed-menu" style="height:1000px; overflow:scroll;">
    <div class="cl-sidebar" data-position="right" data-step="1"
         data-intro="<strong>边侧菜单</strong> <br/> 您的导航信息在这里。。。。。。。。。。。">
        <div class="cl-toggle"><i class="fa fa-bars"></i></div>
        <div class="cl-navblock">
            <div class="menu-space">
                <div class="content">
                    <div class="side-user">
                        <div class="avatar"><img src="images/favicon.png" alt="Avatar"/></div>
                        <div class="info">
                            <a href='javascript:void(0)' onclick='updatePwd()'  id="adminName" style="font-size: x-large;"  >超级管理员</a>
                        </div>
                    </div>
                    <ul class="cl-vnavigation">

                        <li th:each="menu:${menus}" th:if="${menu.parentId } == null">
                            <a href="#">
                                <i class="fa fa-home" th:class="${menu.icon}"></i>
                                <span th:text="${menu.functionName}"></span>
                            </a>
                            <ul class="sub-menu">
                                <li th:each="subMenu:${menus}" th:if="${subMenu.parentId eq menu.id}"><a
                                        th:href="${subMenu.url}" class="J_menuItem"
                                        th:text="${subMenu.functionName}"></a></li>
                                <!--<li><a th:href="@{/role}" class="J_menuItem"> 角色管理</a></li>-->
                                <!--<li><a th:href="@{/navigation}" class="J_menuItem"> 功能管理</a></li>-->
                            </ul>
                        </li>

                    </ul>
                </div>
            </div>
            <div class="text-right collapse-button" style="padding:7px 9px;">
                <button id="sidebar-collapse" class="btn btn-default" style=""><i style="color:#fff;"
                                                                                  class="fa fa-angle-left"></i></button>
            </div>
        </div>
    </div>
    <div class="container-fluid" id="pcont" style="overflow: hidden">

        <div class="page-head fixed content-tabs">
            <button class="roll-nav roll-left J_tabLeft navbar-minimalize"><i class="fa fa-backward"></i>
            </button>
            <nav class="page-tabs J_menuTabs">
                <div class="page-tabs-content">
                    <a href="javascript:;" class="active J_menuTab" data-id="/order">首页</a>
                </div>
            </nav>
            <button class="roll-nav roll-right J_tabRight"><i class="fa fa-forward"></i>
            </button>
            <div class="btn-group roll-nav roll-right" style="margin-left: 0;margin-right: 0">
                <button class="dropdown J_tabClose" data-toggle="dropdown">关闭操作<span class="caret"></span>

                </button>
                <ul role="menu" class="dropdown-menu dropdown-menu-right">
                    <li class="J_tabShowActive"><a>定位当前选项卡</a>
                    </li>
                    <li class="divider"></li>
                    <li class="J_tabCloseAll"><a>关闭全部选项卡</a>
                    </li>
                    <li class="J_tabCloseOther"><a>关闭其他选项卡</a>
                    </li>
                </ul>
            </div>
            <a href="javascript:void(0)" id="logout" class="roll-nav roll-right J_tabExit"><i
                    class="fa fa fa-sign-out"></i> 退出</a>
        </div>

        <!--<div th:include="dashBoard :: dashBoard"></div>-->

        <div class="J_mainContent" id="content-main" style="height: 100%;position: relative">
            <iframe class="J_iframe" name="iframe0" width="100%" height="100%" src="/order" frameborder="0"
                    data-id="/order"></iframe>
        </div>
        <div id="queryWarn">
            <a href="javascript:;" onclick=addTab("/recycleCard?orderStatus=4","1","未预判")>未预判：<span
                    id="preJudgeNum">0</span></a>
            <a href="javascript:;" onclick=addTab("/recycleCard?orderStatus=7","1","等待慢速试充")>等待慢速试充：<span
                    id="waitSlowTrySellNum">0</span></a>
            <a href="javascript:;" onclick=addTab("/recycleCard?orderStatus=5","1","预判面值不符")>预判面值不符：<span
                    id="wrongFaceNum">0</span></a>
            <a href="javascript:;" onclick=addTab("/withdrawList?state=4","1","转账异常")>转账异常：<span
                    id="transferAbnormal">0</span></a>
        </div>
    </div>
    <div class="modal inmodal fade" id="myModal" tabindex="-1" role="dialog" data-backdrop="static"
         aria-hidden="true">
        <div class="modal-dialog " style="width: 1016px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" id="hideModal" class="close">&times;<span class="sr-only">Close</span>
                    </button>
                    <h4 class="modal-title">交接班</h4>
                </div>
                <div class="modal-body" style="height: 460px;overflow: auto;">
                    <table data-classes="table table-hover table-condensed"
                           id="dataTableDetail"
                           data-mobile-responsive="true">
                    </table>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel2">修改密码</h4>
                </div>
                <div class="modal-body">

                    <form class="form-horizontal"
                          id="updateForm">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">原密码：<span class="text-danger">*</span></label>
                            <div class="col-sm-10">
                                <input type="password" class="form-control" placeholder="原密码" id="oldPwd" name="oldPwd">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">新密码：<span class="text-danger">*</span></label>
                            <div class="col-sm-10">
                                <input type="password" class="form-control" placeholder="新密码"  name="newPwd" id="newPwd">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">再次输入：<span class="text-danger">*</span></label>
                            <div class="col-sm-10">
                                <input type="password" class="form-control" placeholder="再次输入"  name="repeatPwd">
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" id="updatePassword">确定</button>
                </div>
            </div>
        </div>
    </div>
</div>

<div th:include="js :: js"></div>
<script>
    jQuery.validator.addMethod("isNormalPwd", function(value, element) {
        var tel = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,12}$/;
        return this.optional(element) || (tel.test(value));
    }, "请输入6-12位字母数字组合");
    $("#updateForm").validate({
        rules: {
            oldPwd: {
                required: true,
            },
            newPwd: {
                required: true,
                isNormalPwd:true
            },
            repeatPwd: {
                required: true,
                equalTo:'#newPwd'
            }
        },
        errorClass: "help-inline",
        errorElement: "p",
        highlight: function (element, errorClass, validClass) {
            $(element).parents('.control-group').addClass('error');
        },
        unhighlight: function (element, errorClass, validClass) {
            $(element).parents('.control-group').removeClass('error');
        }
    });
    $("#dataTableDetail").bootstrapTable({
        url: 'AdminInterface/queryTitle',
        classes: 'table',
        height: document.body.clientHeight - 60,
        pageSize: 30,
        pageList: [30, 50, 100],
        uniqueId: 'id',
        sidePagination: 'server',
        striped: true,
        queryParamsType: '',
        queryParams: queryParams,
        responseHandler: function (res) {
            return {
                "rows": res
            };
        },
        columns: [
            {
                formatter: function (v, row, index) {
                    return index + 1;
                }
            },
            {
                align: 'center',
                field: 'id',
                title: '编号'
            },
            {
                align: 'center',
                field: 'title',
                title: '标题',
                formatter: function (v, o) {
                    return '<a href="javascript:void(0)" name="createLink" onclick="editSupFunc(' + o.id + ')">' + o.title + '</a>'
                }
            }, {
                align: 'center',
                field: 'readStatus',
                title: '读否',
                formatter: function (v, row, index) {
                    if (v == 0 || v == "0") {
                        return '<a href="javascript:void(0)" name="createLink" onclick="editSupFunc(' + row.id + ')">已读</a>'
                    } else {
                        return '<a href="javascript:void(0)" name="createLink" onclick="editSupFunc(' + row.id + ')">未读</a>'
                    }
                }
            }, {
                align: 'center',
                field: 'adminName',
                title: '发布人'
            }, {
                align: 'center',
                field: 'type',
                title: '交接性质',
                formatter: function (v, row, index) {
                    switch (v) {
                        case 1:
                            return "正常";
                            break;
                        case 2:
                            return "一般";
                            break;
                        case 3:
                            return "重点注意";
                            break;
                        case 4:
                            return "<span style='color: red'>全体注意</span>";
                            break;
                        case 5:
                            return "新增渠道";
                            break;
                    }
                }
            }, {
                width: '150px',
                align: 'center',
                field: 'sendTime',
                title: '发布时间'
            }, {
                width: '150px',
                align: 'center',
                field: 'validity',
                title: '有效期至',
            }
        ]
    });
    $('#myModal').modal("show")
    $.ajax({
        type: "POST",
        url: "/AdminInterface/getCurrentAdmin",
        async: false,
        success: function (data) {
            if (data != "") {
                $("#adminName").html(data)
            } else {
                window.location.href = "/logout";
            }
        },
        error: function () {
            window.location.href = "/logout";
        }
    });

    setInterval(function () {
        queryOrderTotal();
        queryNewSubmitBatch();
    }, 5000);

    function queryOrderTotal() {
        $.ajax({
            type: "post",
            url: "/MonitorController/queryOrderTotal",
            dataType: "json",
            async: false,
            cache: false,
            success: function (data) {
                $("#preJudgeNum").text(data.preJudge);
                $("#waitSlowTrySellNum").text(data.waitSlowTrySell);
                $("#wrongFaceNum").text(data.wrongFace);
                $("#transferAbnormal").text(data.transferAbnormal);
            }
        });
    }
    function updatePwd() {
        $("#myModal2").modal("show");
    }
    $("#updatePassword").click(function () {
        var v=$("#updateForm").valid();
        if(!v){
            return;
        }
        $.ajax({
            type: "GET",
            url: "AdminInterface/modifyPwd",
            data: $("#updateForm").serialize(),
            dataType: "json",
            success: function (data) {
                if(data.success){
                    layer.msg("修改成功，您需要重新登录")
                    $("#myModal2").modal("hide");
                    setTimeout(function () {
                        window.location.reload(1);
                    },3000)
                }else {
                    layer.msg('修改失败!'+data.message)
                }
            },
            beforeSend: function () {
            }
        });
    })
    function queryNewSubmitBatch() {
        $("#gritter-notice-wrapper").empty();
        $.ajax({
            type: "post",
            url: "/MonitorController/getCacheData",
            dataType: "json",
            cache: false,
            success: function (data) {
                if (data != null) {
                    $.gritter.add({
                        position: 'bottom-right',
                        title: 'SUP收卡新批次上传',
                        image: 'images/info.png',
                        text: '<p>批次号：' + data.batchId + '</p>' +
                        '<p>' + getArea(data.area) + productTypeConvert(data.productType) + data.face + "元   " + data.total + '张</p>',
                        class_name: 'info'
                    });
                }
            }
        });
    }

    function getArea(v) {
        if (v == "0") {
            return "全国"
        }else{
            return v;
        }
    }

    $("#logout").click(function () {
        $.confirm({
            title: '确认!',
            content: '确定要退出吗？',
            confirm: function () {
                window.location.href = "/logout";
            },
            cancel: function () {

            }
        });
    })
    $("#hideModal").click(function () {
        $.ajax({
            type: "POST",
            url: "AdminInterface/queryClose",
            dataType: "json",
            success: function (data) {
                if (data) {
                    $('#myModal').modal("hide")
                } else {
                    layer.msg("有未读的交接班!")
                }
            }
        });
    })

    function queryParams(params) {
        return {
            pageSize: params.pageSize,
            pageNumber: params.pageNumber,
        };
    }

    //弹出
    function editSupFunc(objid) {
        window.open("/workLogInfo?id=" + objid);
    }
</script>
</body>

</html>
